package com.neusoft.resturant.controller;

import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResUsers;
import com.neusoft.resturant.service.IResUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户Controller
 * 
 * @author zhengzijia0934
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/api/users")
public class ResUsersController
{
    @Autowired
    private IResUsersService resUsersService;

    /**
     * 查询用户列表
     */
    @GetMapping("/list")
    public R list(ResUsers resUsers)
    {

        List<ResUsers> list = resUsersService.selectResUsersList(resUsers);
        return R.success(list);
    }

    /**
     * 导出用户列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, ResUsers resUsers)
    {
        List<ResUsers> list = resUsersService.selectResUsersList(resUsers);

    }

    /**
     * 获取用户详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.success(resUsersService.selectResUsersById(id));
    }

    /**
     * 新增用户
     */
    @PostMapping
    public R add(@RequestBody ResUsers resUsers)
    {
        return R.toAjax(resUsersService.insertResUsers(resUsers));
    }

    /**
     * 修改用户
     */
    @PutMapping
    public R edit(@RequestBody ResUsers resUsers)
    {
        return R.toAjax(resUsersService.updateResUsers(resUsers));
    }

    /**
     * 删除用户
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resUsersService.deleteResUsersByIds(ids));
    }
}
